//
//  ComprehensiveSyntaxTest.h
//  test_simple_project
//
//  综合语法特性测试文件
//  包含Phase 2和Phase 3的各种Objective-C语法特性
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

// 前向声明 - Phase 3特性
@class TestDataModel;
@class TestNetworkManager;
@protocol TestDataSourceProtocol;
@protocol TestDelegateProtocol;

// 协议声明 - 包含协议一致性
@protocol TestDataSourceProtocol <NSObject>
@required
- (NSInteger)numberOfItems;
- (id)itemAtIndex:(NSInteger)index;

@optional
- (NSString *)titleForItemAtIndex:(NSInteger)index;
@end

@protocol TestDelegateProtocol <NSObject>
@optional
- (void)didSelectItem:(id)item atIndex:(NSInteger)index;
- (BOOL)shouldSelectItem:(id)item atIndex:(NSInteger)index;
@end

// 协议继承 - 测试协议一致性
@protocol TestAdvancedProtocol <TestDataSourceProtocol, TestDelegateProtocol>
- (void)performAdvancedOperation;
@end

// 主测试类 - 包含协议一致性
@interface ComprehensiveSyntaxTest : NSObject <TestDataSourceProtocol, TestDelegateProtocol>

// Phase 1: ARC内存管理限定符测试
@property (strong, nonatomic) NSString *strongProperty;
@property (weak, nonatomic) id<TestDelegateProtocol> weakDelegate;
@property (copy, nonatomic) NSString *textContent;  // 修复命名约定问题
@property (assign, nonatomic) NSInteger assignProperty;
@property (unsafe_unretained, nonatomic) NSObject *unsafeProperty;

// 原子性和非原子性属性
@property (atomic, strong) NSMutableArray *atomicArray;
@property (nonatomic, strong) NSMutableDictionary *nonatomicDictionary;

// 只读和读写属性
@property (readonly, strong, nonatomic) NSString *readonlyProperty;
@property (readwrite, strong, nonatomic) NSString *readwriteProperty;

// Phase 3: 可用性注解测试
@property (strong, nonatomic) NSString *modernProperty API_AVAILABLE(ios(10.0));
@property (strong, nonatomic) NSString *deprecatedProperty API_DEPRECATED("Use modernProperty instead", ios(8.0, 12.0));

// 类方法声明 - Phase 1增强
+ (instancetype)sharedInstance;
+ (NSString *)applicationVersion;
+ (BOOL)isValidEmail:(NSString *)email;
+ (void)performClassOperation API_AVAILABLE(ios(11.0));

// 实例方法声明 - Phase 1增强
- (instancetype)initWithConfiguration:(NSDictionary *)configuration;
- (void)performRiskyOperation;
- (void)performSynchronizedOperation;
- (void)demonstrateExceptionHandling;

// 可用性注解方法 - Phase 3特性
- (void)modernMethod API_AVAILABLE(ios(10.0));
- (void)deprecatedMethod API_DEPRECATED("Use modernMethod instead", ios(8.0, 12.0));
- (void)conditionalMethod API_AVAILABLE(ios(9.0)) API_UNAVAILABLE(watchos);

@end

// 类扩展 - Phase 2特性
@interface ComprehensiveSyntaxTest ()

// 私有属性
@property (strong, nonatomic) NSMutableArray *privateDataArray;
@property (weak, nonatomic) id<TestDataSourceProtocol> privateDataSource;
@property (strong, nonatomic) dispatch_queue_t privateQueue;

// 私有方法
- (void)privateMethod;
- (void)setupPrivateData;
- (void)handlePrivateNotification:(NSNotification *)notification;

@end

// 分类声明 - 用于对比类扩展
@interface ComprehensiveSyntaxTest (Utilities)

// 工具方法
- (NSString *)formattedDescription;
- (void)logCurrentState;
- (NSDictionary *)toDictionary;

@end

@interface ComprehensiveSyntaxTest (NetworkOperations)

// 网络操作方法
- (void)fetchDataWithCompletion:(void(^)(NSData *data, NSError *error))completion;
- (void)uploadData:(NSData *)data completion:(void(^)(BOOL success, NSError *error))completion;

@end

// 测试数据模型类
@interface TestDataModel : NSObject

@property (strong, nonatomic) NSString *identifier;
@property (strong, nonatomic) NSString *title;
@property (strong, nonatomic) NSDate *createdDate;
@property (assign, nonatomic) NSInteger priority;

+ (instancetype)modelWithDictionary:(NSDictionary *)dictionary;
- (NSDictionary *)toDictionary;

@end

// 测试网络管理器类 - 包含更多协议一致性
@interface TestNetworkManager : NSObject <NSURLSessionDelegate, NSURLSessionDataDelegate>

@property (strong, nonatomic) NSURLSession *session;
@property (weak, nonatomic) id<TestDelegateProtocol> delegate;

+ (instancetype)sharedManager;
- (void)performNetworkRequest:(NSURLRequest *)request 
                   completion:(void(^)(NSData *data, NSURLResponse *response, NSError *error))completion;

@end

// 枚举定义 - 测试枚举语法
typedef NS_ENUM(NSInteger, TestOperationType) {
    TestOperationTypeRead = 0,
    TestOperationTypeWrite,
    TestOperationTypeDelete,
    TestOperationTypeUpdate
};

typedef NS_OPTIONS(NSUInteger, TestPermissions) {
    TestPermissionsNone = 0,
    TestPermissionsRead = 1 << 0,
    TestPermissionsWrite = 1 << 1,
    TestPermissionsDelete = 1 << 2,
    TestPermissionsAll = TestPermissionsRead | TestPermissionsWrite | TestPermissionsDelete
};

// 块类型定义 - 测试块语法
typedef void(^TestCompletionBlock)(BOOL success, NSError *error);
typedef id(^TestTransformBlock)(id input);
typedef BOOL(^TestPredicateBlock)(id object);

// 常量声明
FOUNDATION_EXPORT NSString * const TestNotificationName;
FOUNDATION_EXPORT NSString * const TestErrorDomain;
FOUNDATION_EXPORT NSInteger const TestDefaultTimeout;

// 全局函数声明 - 包含可用性注解
void TestGlobalFunction(void);
NSString *TestFormatString(NSString *format, ...) NS_FORMAT_FUNCTION(1, 2);
void TestModernGlobalFunction(void) API_AVAILABLE(ios(11.0));
void TestDeprecatedGlobalFunction(void) API_DEPRECATED("Use TestModernGlobalFunction instead", ios(8.0, 12.0));
